﻿
namespace EasyStep.TestEditor.Controls.History
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using EasyStep.TestExecution.Interfaces;
    using System.Drawing;
    using EasyStep.WinForms.Controls;
    using EasyStep.TestEditor.Test;
    using EasyStep.Business.Interfaces;
    using EasyStep.TestExecution.Data;
    using EasyStep.TestExecution;
    using System.IO;
    using EasyStep.Business.Constants;
    using System.Diagnostics;
    using System.Threading;


    public class TestHistoryPanel : UserControl
    {
        private const string loading = "loading...";
        private ITestDataContext DataContext { get; set; }
        public TestHistoryPanel()
        {
            InitializeComponent();
            trvHistory.AfterExpand += new TreeViewEventHandler(trvHistory_AfterExpand);
            trvHistory.BeforeCollapse += new TreeViewCancelEventHandler(trvHistory_BeforeCollapse);
            trvHistory.AfterSelect += new TreeViewEventHandler(trvHistory_AfterSelect);
            contextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(contextMenuStrip_Opening);
        }
        protected override void OnLoad(EventArgs e)
        {
            var frm = (ParentForm as ITestContextForm);
            if (frm == null) return;
            DataContext = frm.DataContext;
            ReInit();
            base.OnLoad(e);
        }

        public void ReInit()
        {
            trvHistory.Nodes.Clear();
            SetControlsStates(null);
            BindHistoryTree();
            if (string.IsNullOrEmpty(DataContext.CurrentProject)) return;

            //select current history
            var curPrName = Path.GetFileName(DataContext.CurrentProject);
            var curTstName = Path.GetFileName(DataContext.CurrentTest);
            foreach (TreeNode pnode in trvHistory.Nodes)
                if (pnode.Text.Equals(curPrName, StringComparison.OrdinalIgnoreCase))
                {
                    SelectAndExpandNode(pnode, () =>
                    {
                        foreach (TreeNode tnode in pnode.Nodes)
                            if (tnode.Text.Equals(curTstName, StringComparison.OrdinalIgnoreCase))
                            {
                                SelectAndExpandNode(tnode, () =>
                                    SelectAndExpandNode(tnode.FirstNode, () =>
                                        SelectAndExpandNode(tnode.FirstNode.FirstNode, () => { })
                                    )
                                );
                                break;
                            };
                    });
                    break;
                }
        }

        private void contextMenuStrip_Opening(object sender, System.ComponentModel.CancelEventArgs e)
        {
            var p = new Point(Cursor.Position.X, Cursor.Position.Y);
            p = trvHistory.PointToClient(p);
            var node = trvHistory.GetNodeAt(p);
            if (node != null)
                trvHistory.SelectedNode = node;
        }






        private void SelectAndExpandNode(TreeNode node, Action onFinish)
        {
            if (node == null) return;
            trvHistory.SelectedNode = node;
            node.Expand();
            if (node.Nodes.Count > 0)
                onFinish();
        }
        #region tree events
        void trvHistory_AfterSelect(object sender, TreeViewEventArgs e)
        {
            SetControlsStates(e.Node);
            pnlCurPath.Controls.Clear();
            var parent = e.Node;
            while (parent != null)
            {
                var lbl = new LinkLabel() { Text = parent.Text, ImageIndex = parent.ImageIndex, ImageList = this.imagesList, AutoSize = true, Dock = DockStyle.Left, Margin = new Padding(10, 10, 0, 10), Padding = new System.Windows.Forms.Padding(20, 0, 5, 0), ImageAlign = ContentAlignment.MiddleLeft, TextAlign = ContentAlignment.MiddleLeft, LinkBehavior = LinkBehavior.HoverUnderline, LinkColor = System.Drawing.SystemColors.MenuHighlight };
                pnlCurPath.Controls.Add(lbl);
                var width = lbl.Width;
                lbl.AutoSize = false;
                lbl.Width = width;
                var node = parent;
                lbl.LinkClicked += (s, le) =>
                {
                    trvHistory.SelectedNode = node;
                };
                parent = parent.Parent;
                if (parent != null)
                    pnlCurPath.Controls.Add(new Label() { Text = "", ImageList = this.imagesList, Dock = DockStyle.Left, ImageKey = "separator", Height = 16, Width = 7 });
            }
            RefreshResultDetail(e.Node);
            e.Node.Collapse(false);
        }

        private void SetControlsStates(TreeNode node)
        {
            var projectNode = GetParentNode(node, 0);
            var testNode = GetParentNode(projectNode, 1);
            var sessionNode = GetParentNode(testNode, 2);
            var browserNode = GetParentNode(sessionNode, 3);

            deleteAllForProjectToolStripMenuItem.Enabled = projectNode != null;
            deleteAllTestToolStripMenuItem.Enabled = testNode != null;
            deleteAllResultsToolStripMenuItem.Enabled = sessionNode != null;
            tsbOpen.Enabled = projectNode != null;
            tsbDelete.Enabled = projectNode != null;
        }


        private void RefreshResultDetail(TreeNode selectedNode)
        {
            var projectNode = GetParentNode(selectedNode, 0);
            var testNode = GetParentNode(selectedNode, 1);
            if (testNode == null) return;
            var sessionNode = GetParentNode(selectedNode, 2);
            if (sessionNode == null) return;
            var browserNode = GetParentNode(selectedNode, 3);
            var stepNode = selectedNode;
            var executionPath = "";
            while (browserNode != null && stepNode.Level > browserNode.Level)
            {
                executionPath = Path.Combine(stepNode.Text, executionPath);
                stepNode = stepNode.Parent;
            }
            executionPath = Path.Combine(sessionNode.Text, executionPath);
            pnlTestSteps.Visible = false;
            var results = (browserNode == null) ? null : DataContext.TestHistoryManager.GetTestResultSteps(projectNode.Text, testNode.Text, executionPath, browserNode.Text, true);
            var actions = DataContext.ActionManager.GetAll();
            pnlTestSteps.Controls.Clear();
            var i = 0;
            if (results != null)
                foreach (var ritem in results)
                {
                    var rcontrol = new TestStepViewControl(ritem.StepInfo, actions, this.imagesList) { Name = "sc_" + i, Dock = DockStyle.Top, Visible = true };
                    pnlTestSteps.Controls.Add(rcontrol);
                    rcontrol.SetResult(ritem);
                    rcontrol.BringToFront();
                }
            else
                foreach (var brKVPair in DataContext.TestHistoryManager.GetTestResultBrowsers(projectNode.Text, testNode.Text, sessionNode.Text, false))
                    foreach (var ritem in brKVPair.Value)
                    {
                        var rcontrol = pnlTestSteps.Controls["sc_" + ritem.StepInfo.Id.ToString()] as TestStepViewControl;
                        if (rcontrol == null)
                        {
                            rcontrol = new TestStepViewControl(ritem.StepInfo, actions, this.imagesList) { Name = "sc_" + ritem.StepInfo.Id.ToString(), Dock = DockStyle.Top, Visible = true };
                            pnlTestSteps.Controls.Add(rcontrol);
                            rcontrol.SetResult(ritem);
                            rcontrol.BringToFront();
                        }
                        else
                            rcontrol.SetResult(ritem);
                    }

            pnlTestSteps.Visible = true;
        }

        private TreeNode GetParentNode(TreeNode selectedNode, int level)
        {
            if (selectedNode == null) return null;
            var node = selectedNode;
            while (node != null && node.Level != level)
            {
                node = node.Parent;
            }
            return node;
        }

        void trvHistory_AfterExpand(object sender, TreeViewEventArgs e)
        {
            if (e.Node.Tag is int && (int)e.Node.Tag == 1) return;
            BindHistoryTree(e.Node);
        }
        void trvHistory_BeforeCollapse(object sender, TreeViewCancelEventArgs e)
        {
            if (e.Node.Tag is int && (int)e.Node.Tag == 1) return;
            e.Node.Nodes.Clear();
            e.Node.Nodes.Add(loading);
        }

        #endregion
        Thread analizeThread;
        Thread showNodesThread;

        private void BindHistoryTree(TreeNode current = null)
        {
            if (current != null) current.Nodes.Clear();
            var projNode = GetParentNode(current, 0);
            var testNode = projNode == null ? null : GetParentNode(current, 1);
            var sessionNode = testNode == null ? null : GetParentNode(current, 2);
            var browserNode = sessionNode == null ? null : GetParentNode(current, 3);
            var tstepNode = browserNode == null ? null : GetParentNode(current, 4);
            if (projNode == null)
                trvHistory.Nodes.AddRange(DataContext.TestHistoryManager.GetAllProjects()
                    .Select(pname => new TreeNode(pname, GetNodeImage("project"), GetNodeImage("project", true), new TreeNode[] { new TreeNode(loading) }) { ContextMenuStrip = contextMenuStrip })
                    .ToArray()
                );
            else if (testNode == null)
            {
                current.Nodes.AddRange(DataContext.TestHistoryManager.GetProjectTests(projNode.Text)
                    .Select(tname => new TreeNode(tname, GetNodeImage("test"), GetNodeImage("test", true), new TreeNode[] { new TreeNode(loading) }) { ContextMenuStrip = contextMenuStrip })
                    .ToArray()
                );
            }
            else if (sessionNode == null)
            {
                AbortThread(analizeThread);
                analizeThread = new Thread(() =>
                    {
                        Invoke(new Action(() =>
                        {
                            current.Nodes.AddRange(DataContext.TestHistoryManager.GetTestResults(projNode.Text, testNode.Text)
                                .Select(rname => AnalizeTestResult(projNode.Text, testNode.Text, rname
                                    ,
                                    (result, childNodes) => new TreeNode(rname, GetImageIndex(result), GetImageIndex(result, true), childNodes.ToArray()) { Tag = 1, ContextMenuStrip = contextMenuStrip }
                                    ,
                                    (browsername, result) => new TreeNode(browsername, GetImageIndex(result), GetImageIndex(result, true), new TreeNode[] { new TreeNode(loading) }) { ContextMenuStrip = contextMenuStrip }
                                )).ToArray()
                            );
                        }));
                    });
                analizeThread.Start();
            }
            else if (tstepNode == null)
            {
                AbortThread(showNodesThread);
                showNodesThread = new Thread(() =>
                {
                    foreach (var stepResult in DataContext.TestHistoryManager.GetTestResultSteps(projNode.Text, testNode.Text, sessionNode.Text, browserNode.Text, false))
                    {
                        var node = ConvertStepResultToNode(stepResult);
                        if (node != null)
                            Invoke(new Action(() =>
                           current.Nodes.Add(node)
                       ));
                    }
                });
                showNodesThread.Start();
            }
        }

        private void AbortThread(Thread thread)
        {
            if (thread != null && thread.IsAlive)
                thread.Abort();
        }

        private TreeNode ConvertStepResultToNode(TestStepResult stepResult)
        {
            if (stepResult == null) return null;
            var result = new TreeNode(stepResult.StepInfo.OrderNr.ToString(), GetImageIndex(stepResult.Result), GetImageIndex(stepResult.Result, true)) { Tag = 1 };
            result.ToolTipText = DataContext.TestHistoryManager.Convert(stepResult);
            if (stepResult.Children == null) return result;
            foreach (var item in stepResult.Children)
            {
                var node = ConvertStepResultToNode(item);
                if (node != null)
                    result.Nodes.Add(node);
            }
            return result;
        }
        private T AnalizeTestResult<T>(string projName, string testName, string resName, Func<ExecutionResult, List<T>, T> onFinished, Func<string, ExecutionResult, T> onProcessResultItem)
        {
            var existFailed = false;
            var existInProgress = false;
            var subResults = new List<T>();
            foreach (var britem in DataContext.TestHistoryManager.GetTestResultBrowsers(projName, testName, resName))
            {
                try
                {
                    var itemResult = AnalizeTestBrowserResult(britem.Value);
                    subResults.Add(onProcessResultItem(britem.Key, itemResult));
                    if (itemResult == ExecutionResult.Failed)
                        existFailed = true;
                    else if (itemResult == ExecutionResult.InProgress)
                        existInProgress = true;
                }
                catch (Exception ex)
                {
                    DataContext.Log.Error(string.Format("Can't process browser result! proj:{0}, test:{1}, res:{2}, browser:{3}, error:{4}",
                        projName, testName, resName, britem.Key, ex.Message), ex);
                    existFailed = true;
                }
            }
            var testResult = existFailed ? ExecutionResult.Failed : existInProgress ? ExecutionResult.InProgress : ExecutionResult.Success;
            var resultNode = onFinished(testResult, subResults);
            return resultNode;
        }

        private ExecutionResult AnalizeTestBrowserResult(IEnumerable<TestStepResult> results)
        {
            if (results.Where(ri => ri.Result == ExecutionResult.Failed).Any())
                return ExecutionResult.Failed;
            if (results.Where(ri => ri.Result == ExecutionResult.InProgress).Any())
                return ExecutionResult.InProgress;
            return ExecutionResult.Success;
        }


        private void openFolderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var current = trvHistory.SelectedNode;
            if (current == null) return;
            var projNode = GetParentNode(current, 0);
            var testNode = projNode == null ? null : GetParentNode(current, 1);
            var sessionNode = testNode == null ? null : GetParentNode(current, 2);
            var browserNode = sessionNode == null ? null : GetParentNode(current, 3);
            var path = DataContext.PathReplacements[MainApplicationServiceConstants.FileSystemDataStoragePath];
            if (projNode != null) path = Path.Combine(path, projNode.Text);
            if (testNode != null) path = Path.Combine(path, testNode.Text);
            if (sessionNode != null) path = Path.Combine(path, sessionNode.Text);


            using (var p = System.Diagnostics.Process.Start(path))
            {
                if (p != null)
                    p.Close();
            }
        }

        private void tsbOpen_Click(object sender, EventArgs e)
        {
            openFolderToolStripMenuItem_Click(sender, e);
        }

        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var node = trvHistory.SelectedNode;
            if (node == null) return;
            var projectNode = GetParentNode(node, 0);
            var testNode = GetParentNode(node, 1);
            var sessionNode = GetParentNode(node, 2);
            var browserNode = GetParentNode(node, 3);
            var path = DataContext.PathReplacements[MainApplicationServiceConstants.FileSystemDataStoragePath];
            if (projectNode != null) path = Path.Combine(path, projectNode.Text);
            if (testNode != null) path = Path.Combine(path, testNode.Text);
            else
            {
                ConfirmDelete("All Test for project", projectNode, () => Directory.Delete(path, true));
                return;
            }
            if (sessionNode != null) path = Path.Combine(path, sessionNode.Text);
            else
            {
                ConfirmDelete("All Test Results", testNode, () => Directory.Delete(path, true));
                return;
            }
            ConfirmDelete("Results", sessionNode, () => Directory.Delete(path, true));
        }

        private void ConfirmDelete(string deleteType, TreeNode node, Action onConfirmed)
        {
            var parent = node;
            var nodesPath = "";
            while (parent != null)
            {
                nodesPath = string.Format("[{0}] > {1}", parent.Text, nodesPath);
                parent = parent.Parent;
            }
            var result = MessageBox.Show("Are you really want to delete results for:\r\n" + nodesPath + " [*.*]", "Confirm delete " + deleteType, MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            if (result == DialogResult.Yes)
                try
                {
                    pnlTestSteps.Controls.Clear();
                    onConfirmed();
                    pnlCurPath.Controls.Clear();
                    if (node != null && node.Parent != null)
                    {
                        parent = node.Parent;
                        parent.Collapse();
                        parent.Expand();
                    }
                    else
                        ReInit();
                }
                catch (Exception ex)
                {
                    DataContext.Log.Fatal(ex);
                    MessageBox.Show("Can't Delete " + nodesPath + "\r\n\r\n" + ex.Message + "\r\n", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
        }

        private void completellyDeleteAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var path = DataContext.PathReplacements[MainApplicationServiceConstants.FileSystemDataStoragePath];
            ConfirmDelete("All", null, () => Directory.Delete(path, true));
        }

        private void deleteAllForProjectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var node = trvHistory.SelectedNode;
            if (node == null) return;
            var projectNode = GetParentNode(node, 0);
            var path = DataContext.PathReplacements[MainApplicationServiceConstants.FileSystemDataStoragePath];
            if (projectNode != null) path = Path.Combine(path, projectNode.Text);
            ConfirmDelete("All Test for project", projectNode, () => Directory.Delete(path, true));
        }

        private void deleteAllTestToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var node = trvHistory.SelectedNode;
            if (node == null) return;
            var projectNode = GetParentNode(node, 0);
            var testNode = GetParentNode(node, 1);
            var path = DataContext.PathReplacements[MainApplicationServiceConstants.FileSystemDataStoragePath];
            if (testNode == null) return;
            path = Path.Combine(path, testNode.Text);

            ConfirmDelete("All Test Results", testNode, () => Directory.Delete(path, true));
        }

        private void deleteAllResultsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var node = trvHistory.SelectedNode;
            if (node == null) return;
            var projectNode = GetParentNode(node, 0);
            var testNode = GetParentNode(node, 1);
            var sessionNode = GetParentNode(node, 2);
            var browserNode = GetParentNode(node, 3);
            var path = DataContext.PathReplacements[MainApplicationServiceConstants.FileSystemDataStoragePath];
            if (projectNode != null) path = Path.Combine(path, projectNode.Text);
            if (testNode != null) path = Path.Combine(path, testNode.Text);
            if (sessionNode != null) path = Path.Combine(path, sessionNode.Text);
            else return;
            ConfirmDelete("Results", sessionNode, () => Directory.Delete(path, true));
        }



        private int GetImageIndex(ExecutionResult result, bool forSelectedNode = false)
        {
            return GetNodeImage(result.ToString(), forSelectedNode);
        }
        private int GetNodeImage(string key, bool selected = false)
        {
            var index = imagesList.Images.IndexOfKey(key);
            return index >= 0 ? index : 0;
        }

        #region designer generated code

        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TestHistoryPanel));
            this.splitContainer = new System.Windows.Forms.SplitContainer();
            this.trvHistory = new System.Windows.Forms.TreeView();
            this.imagesList = new System.Windows.Forms.ImageList(this.components);
            this.pnlTestSteps = new System.Windows.Forms.Panel();
            this.pnlTestInfo = new System.Windows.Forms.Panel();
            this.pnlCurPath = new System.Windows.Forms.Panel();
            this.pnlResultStatus = new System.Windows.Forms.Panel();
            this.toolStrip1 = new System.Windows.Forms.ToolStrip();
            this.tsbDelete = new System.Windows.Forms.ToolStripSplitButton();
            this.deleteAllResultsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.deleteAllTestToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.deleteAllForProjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.completellyDeleteAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.tsbOpen = new System.Windows.Forms.ToolStripButton();
            this.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
            this.openFolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
            this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator();
            this.zipSendToToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
            this.splitContainer.Panel1.SuspendLayout();
            this.splitContainer.Panel2.SuspendLayout();
            this.splitContainer.SuspendLayout();
            this.pnlTestInfo.SuspendLayout();
            this.pnlResultStatus.SuspendLayout();
            this.toolStrip1.SuspendLayout();
            this.contextMenuStrip.SuspendLayout();
            this.SuspendLayout();
            // 
            // splitContainer
            // 
            this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
            this.splitContainer.Location = new System.Drawing.Point(0, 0);
            this.splitContainer.Name = "splitContainer";
            // 
            // splitContainer.Panel1
            // 
            this.splitContainer.Panel1.Controls.Add(this.trvHistory);
            // 
            // splitContainer.Panel2
            // 
            this.splitContainer.Panel2.Controls.Add(this.pnlTestSteps);
            this.splitContainer.Panel2.Controls.Add(this.pnlTestInfo);
            this.splitContainer.Panel2.Controls.Add(this.pnlResultStatus);
            this.splitContainer.Size = new System.Drawing.Size(828, 460);
            this.splitContainer.SplitterDistance = 150;
            this.splitContainer.SplitterWidth = 3;
            this.splitContainer.TabIndex = 0;
            // 
            // trvHistory
            // 
            this.trvHistory.Dock = System.Windows.Forms.DockStyle.Fill;
            this.trvHistory.HideSelection = false;
            this.trvHistory.ImageIndex = 0;
            this.trvHistory.ImageList = this.imagesList;
            this.trvHistory.ItemHeight = 20;
            this.trvHistory.Location = new System.Drawing.Point(0, 0);
            this.trvHistory.Name = "trvHistory";
            this.trvHistory.SelectedImageIndex = 0;
            this.trvHistory.ShowLines = false;
            this.trvHistory.ShowNodeToolTips = true;
            this.trvHistory.Size = new System.Drawing.Size(150, 460);
            this.trvHistory.StateImageList = this.imagesList;
            this.trvHistory.TabIndex = 1;
            // 
            // imagesList
            // 
            this.imagesList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imagesList.ImageStream")));
            this.imagesList.TransparentColor = System.Drawing.Color.Transparent;
            this.imagesList.Images.SetKeyName(0, "execute");
            this.imagesList.Images.SetKeyName(1, "project");
            this.imagesList.Images.SetKeyName(2, "test");
            this.imagesList.Images.SetKeyName(3, "NoResult");
            this.imagesList.Images.SetKeyName(4, "Success");
            this.imagesList.Images.SetKeyName(5, "Failed");
            this.imagesList.Images.SetKeyName(6, "InProgress");
            this.imagesList.Images.SetKeyName(7, "info");
            this.imagesList.Images.SetKeyName(8, "separator");
            // 
            // pnlTestSteps
            // 
            this.pnlTestSteps.AutoScroll = true;
            this.pnlTestSteps.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.pnlTestSteps.Dock = System.Windows.Forms.DockStyle.Fill;
            this.pnlTestSteps.Location = new System.Drawing.Point(0, 40);
            this.pnlTestSteps.Name = "pnlTestSteps";
            this.pnlTestSteps.Size = new System.Drawing.Size(675, 395);
            this.pnlTestSteps.TabIndex = 1;
            // 
            // pnlTestInfo
            // 
            this.pnlTestInfo.AutoScroll = true;
            this.pnlTestInfo.BackColor = System.Drawing.SystemColors.ButtonFace;
            this.pnlTestInfo.Controls.Add(this.pnlCurPath);
            this.pnlTestInfo.Dock = System.Windows.Forms.DockStyle.Top;
            this.pnlTestInfo.Location = new System.Drawing.Point(0, 0);
            this.pnlTestInfo.Name = "pnlTestInfo";
            this.pnlTestInfo.Size = new System.Drawing.Size(675, 40);
            this.pnlTestInfo.TabIndex = 2;
            // 
            // pnlCurPath
            // 
            this.pnlCurPath.AutoSize = true;
            this.pnlCurPath.Dock = System.Windows.Forms.DockStyle.Left;
            this.pnlCurPath.Location = new System.Drawing.Point(0, 0);
            this.pnlCurPath.Name = "pnlCurPath";
            this.pnlCurPath.Size = new System.Drawing.Size(0, 40);
            this.pnlCurPath.TabIndex = 1;
            // 
            // pnlResultStatus
            // 
            this.pnlResultStatus.AutoSize = true;
            this.pnlResultStatus.BackColor = System.Drawing.SystemColors.ButtonFace;
            this.pnlResultStatus.Controls.Add(this.toolStrip1);
            this.pnlResultStatus.Dock = System.Windows.Forms.DockStyle.Bottom;
            this.pnlResultStatus.ForeColor = System.Drawing.SystemColors.MenuHighlight;
            this.pnlResultStatus.Location = new System.Drawing.Point(0, 435);
            this.pnlResultStatus.Name = "pnlResultStatus";
            this.pnlResultStatus.Size = new System.Drawing.Size(675, 25);
            this.pnlResultStatus.TabIndex = 0;
            // 
            // toolStrip1
            // 
            this.toolStrip1.Dock = System.Windows.Forms.DockStyle.Bottom;
            this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.tsbDelete,
            this.tsbOpen});
            this.toolStrip1.Location = new System.Drawing.Point(0, 0);
            this.toolStrip1.Name = "toolStrip1";
            this.toolStrip1.Padding = new System.Windows.Forms.Padding(0, 0, 5, 0);
            this.toolStrip1.Size = new System.Drawing.Size(675, 25);
            this.toolStrip1.TabIndex = 0;
            this.toolStrip1.Text = "toolStrip1";
            // 
            // tsbDelete
            // 
            this.tsbDelete.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
            this.tsbDelete.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.deleteAllResultsToolStripMenuItem,
            this.deleteAllTestToolStripMenuItem,
            this.deleteAllForProjectToolStripMenuItem,
            this.completellyDeleteAllToolStripMenuItem});
            this.tsbDelete.Image = global::EasyStep.TestEditor.Properties.Resources.delete16;
            this.tsbDelete.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.tsbDelete.Name = "tsbDelete";
            this.tsbDelete.Size = new System.Drawing.Size(72, 22);
            this.tsbDelete.Text = "Delete";
            this.tsbDelete.TextImageRelation = System.Windows.Forms.TextImageRelation.TextBeforeImage;
            // 
            // deleteAllResultsToolStripMenuItem
            // 
            this.deleteAllResultsToolStripMenuItem.Name = "deleteAllResultsToolStripMenuItem";
            this.deleteAllResultsToolStripMenuItem.Size = new System.Drawing.Size(279, 22);
            this.deleteAllResultsToolStripMenuItem.Text = "Delete All Results for Selected Iteration ";
            this.deleteAllResultsToolStripMenuItem.ToolTipText = "Delete All results for current test execution, session";
            this.deleteAllResultsToolStripMenuItem.Click += new System.EventHandler(this.deleteAllResultsToolStripMenuItem_Click);
            // 
            // deleteAllTestToolStripMenuItem
            // 
            this.deleteAllTestToolStripMenuItem.Name = "deleteAllTestToolStripMenuItem";
            this.deleteAllTestToolStripMenuItem.Size = new System.Drawing.Size(279, 22);
            this.deleteAllTestToolStripMenuItem.Text = "Delete All For Cur Test";
            this.deleteAllTestToolStripMenuItem.ToolTipText = "Delete all test results for current (selected) test";
            this.deleteAllTestToolStripMenuItem.Click += new System.EventHandler(this.deleteAllTestToolStripMenuItem_Click);
            // 
            // deleteAllForProjectToolStripMenuItem
            // 
            this.deleteAllForProjectToolStripMenuItem.Name = "deleteAllForProjectToolStripMenuItem";
            this.deleteAllForProjectToolStripMenuItem.Size = new System.Drawing.Size(279, 22);
            this.deleteAllForProjectToolStripMenuItem.Text = "Delete All For Current Project";
            this.deleteAllForProjectToolStripMenuItem.ToolTipText = "Delete Test Resutls for current project";
            this.deleteAllForProjectToolStripMenuItem.Click += new System.EventHandler(this.deleteAllForProjectToolStripMenuItem_Click);
            // 
            // completellyDeleteAllToolStripMenuItem
            // 
            this.completellyDeleteAllToolStripMenuItem.Name = "completellyDeleteAllToolStripMenuItem";
            this.completellyDeleteAllToolStripMenuItem.Size = new System.Drawing.Size(279, 22);
            this.completellyDeleteAllToolStripMenuItem.Text = "Delete All";
            this.completellyDeleteAllToolStripMenuItem.ToolTipText = "Completely delete all test results";
            this.completellyDeleteAllToolStripMenuItem.Click += new System.EventHandler(this.completellyDeleteAllToolStripMenuItem_Click);
            // 
            // tsbOpen
            // 
            this.tsbOpen.Image = global::EasyStep.TestEditor.Properties.Resources.openResult16;
            this.tsbOpen.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.tsbOpen.Name = "tsbOpen";
            this.tsbOpen.Size = new System.Drawing.Size(100, 22);
            this.tsbOpen.Text = "Navigate To...";
            this.tsbOpen.ToolTipText = "Could open result folder";
            this.tsbOpen.Click += new System.EventHandler(this.tsbOpen_Click);
            // 
            // contextMenuStrip
            // 
            this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.openFolderToolStripMenuItem,
            this.toolStripMenuItem1,
            this.deleteToolStripMenuItem,
            this.toolStripMenuItem2,
            this.zipSendToToolStripMenuItem});
            this.contextMenuStrip.Name = "contextMenuStrip1";
            this.contextMenuStrip.Size = new System.Drawing.Size(245, 82);
            // 
            // openFolderToolStripMenuItem
            // 
            this.openFolderToolStripMenuItem.Image = global::EasyStep.TestEditor.Properties.Resources.openResult161;
            this.openFolderToolStripMenuItem.Name = "openFolderToolStripMenuItem";
            this.openFolderToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
            | System.Windows.Forms.Keys.O)));
            this.openFolderToolStripMenuItem.Size = new System.Drawing.Size(244, 22);
            this.openFolderToolStripMenuItem.Text = "Open Folder";
            this.openFolderToolStripMenuItem.Click += new System.EventHandler(this.openFolderToolStripMenuItem_Click);
            // 
            // toolStripMenuItem1
            // 
            this.toolStripMenuItem1.Name = "toolStripMenuItem1";
            this.toolStripMenuItem1.Size = new System.Drawing.Size(241, 6);
            // 
            // deleteToolStripMenuItem
            // 
            this.deleteToolStripMenuItem.Image = global::EasyStep.TestEditor.Properties.Resources.delete16;
            this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
            this.deleteToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
            | System.Windows.Forms.Keys.Delete)));
            this.deleteToolStripMenuItem.Size = new System.Drawing.Size(244, 22);
            this.deleteToolStripMenuItem.Text = "Delete";
            this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click);
            // 
            // toolStripMenuItem2
            // 
            this.toolStripMenuItem2.Name = "toolStripMenuItem2";
            this.toolStripMenuItem2.Size = new System.Drawing.Size(241, 6);
            // 
            // zipSendToToolStripMenuItem
            // 
            this.zipSendToToolStripMenuItem.Enabled = false;
            this.zipSendToToolStripMenuItem.Image = global::EasyStep.TestEditor.Properties.Resources.sendMail16;
            this.zipSendToToolStripMenuItem.Name = "zipSendToToolStripMenuItem";
            this.zipSendToToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
            | System.Windows.Forms.Keys.Z)));
            this.zipSendToToolStripMenuItem.Size = new System.Drawing.Size(244, 22);
            this.zipSendToToolStripMenuItem.Text = "&Zip And Send To...";
            // 
            // TestHistoryPanel
            // 
            this.Controls.Add(this.splitContainer);
            this.Name = "TestHistoryPanel";
            this.Size = new System.Drawing.Size(828, 460);
            this.splitContainer.Panel1.ResumeLayout(false);
            this.splitContainer.Panel2.ResumeLayout(false);
            this.splitContainer.Panel2.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
            this.splitContainer.ResumeLayout(false);
            this.pnlTestInfo.ResumeLayout(false);
            this.pnlTestInfo.PerformLayout();
            this.pnlResultStatus.ResumeLayout(false);
            this.pnlResultStatus.PerformLayout();
            this.toolStrip1.ResumeLayout(false);
            this.toolStrip1.PerformLayout();
            this.contextMenuStrip.ResumeLayout(false);
            this.ResumeLayout(false);

        }
        private Panel pnlTestInfo;
        private Panel pnlTestSteps;
        private Panel pnlResultStatus;
        private TreeView trvHistory;
        private ImageList imagesList;
        private System.ComponentModel.IContainer components;
        private Panel pnlCurPath;
        private ContextMenuStrip contextMenuStrip;
        private ToolStripMenuItem openFolderToolStripMenuItem;
        private ToolStripSeparator toolStripMenuItem1;
        private ToolStripMenuItem deleteToolStripMenuItem;
        private ToolStripSeparator toolStripMenuItem2;
        private ToolStripMenuItem zipSendToToolStripMenuItem;
        private ToolStrip toolStrip1;
        private ToolStripSplitButton tsbDelete;
        private ToolStripMenuItem deleteAllResultsToolStripMenuItem;
        private ToolStripMenuItem deleteAllTestToolStripMenuItem;
        private ToolStripMenuItem deleteAllForProjectToolStripMenuItem;
        private ToolStripMenuItem completellyDeleteAllToolStripMenuItem;
        private ToolStripButton tsbOpen;
        private SplitContainer splitContainer;
        #endregion
    }
}
